<template>
  <div>
    <!--** 分页 ***-->
    <div v-if="total" id="page"></div>
    <!--** 分页 end ***-->
  </div>
</template>
<script>
export default {
  props: {
    pageNum: {
      type: Number,
      default: 1
    },
    pageSize: {
      type: Number,
      default: 10
    },
    total: {
      type: Number,
      default: 0
    }
  },
  mounted () {
    setTimeout(() => {
      this.showPage()
    })
  },
  methods: {
    showPage () {
      let that = this
      window.layui.use('laypage', function () {
        window.layui.laypage.render({
          elem: 'page',
          count: that.total, // 数据总数，从服务端得到
          curr: that.pageNum,
          limit: that.pageSize, // 每页显示的条数
          jump: function (obj, first) {
            // 首次不执行
            if (!first) {
              // do something
              that.$emit('changePage', obj.onr)
            }
          }
        })
      })
    }
  }
}
</script>
